import time
from udp import RobotConnection
from settings import *

# Network Connection Init
print "Initializing connection with robot for team " + str(TEAM_NUMBER) + " at 10.0." + str(TEAM_NUMBER) + ".2"
robot = RobotConnection("10.0." + str(TEAM_NUMBER) + ".2")

while True:
    # Set all analogs to max, all buttons on
    print "Setting all analogs MAX, all buttons ON for 10s"
    for i in range(1000):
        
        for thisAnalog in range(12):
            robot.setAnalog(thisAnalog, 255)

        for thisDigital in range(64):
            robot.setDigital(thisDigital, 1)

         # Send the packet and sleep 10ms
        robot.sendPacket()
        time.sleep(0.01)

    # Set all analogs to min, all buttons on
    print "Setting all analogs MIN, all buttons ON for 10s"
    for i in range(1000):
        
        for thisAnalog in range(12):
            robot.setAnalog(thisAnalog, 0)

        for thisDigital in range(64):
            robot.setDigital(thisDigital,1)

        # Send the packet and sleep 10ms
        robot.sendPacket()
        time.sleep(0.01)

    # Set all analogs to off, all buttons off
    print "Setting all analogs OFF, all buttons OFF for 10s"
    for i in range(1000):
        
        for thisAnalog in range(12):
            robot.setAnalog(thisAnalog, 127)

        for thisDigital in range(64):
            robot.setDigital(thisDigital,0)

        # Send the packet and sleep 10ms
        robot.sendPacket()
        time.sleep(0.01)
